﻿package net.wangit.app.user;

import java.util.List;

import net.wangit.UserSupport;
import net.wangit.context.ActionContext;
import net.wangit.jdbc.ColumnRow;
import net.wangit.jdbc.DB;
import net.wangit.jdbc.Table;
import net.wangit.support.action.DefaultAction;
import net.wangit.user.config.AUser;


public class DeleteUserAction extends DefaultAction {

	public void doAction(DB db, ActionContext ac) throws Exception {
		// 同步删除关联数据
		List<Table> tables = ac.getTables();
		Table table = tables.get(0);
		List<ColumnRow> rows = table.getRows();
		for (int i = 0; i < rows.size(); i++) {
			ColumnRow row = rows.get(i);
			if (row.isDeleteRow()) {
				UserSupport.deleteUser(db, row.getPrimaryKey(AUser.USER_ID));
			}
		}
		// delete
		super.doAction(db, ac);
	}

}
